﻿<cfscript>
/** 
* DataBase Frameworks - Sequence
* 
* @hint "DataBase Frameworks - Sequence - MeasureSet" 
*/ 

component 
	displayname="public.service.db.senate.sequence.MeasureSet" 
	output=false 
	accessors=true 
	{

	property type="string" name="Measure" hint="指标分类";
	
	/**
	* @hint "初始化对象"
	*/
	public function init() output=false {
		return this;
	}
	
	/**
	* @hint "自定义主键规则"
	*/
	public string function getID() output=false {
		
		var nextID = getMeasure() & "01";

		/* 
			主键生成规则 
			
			评判模式为3位 1位指标分类 + 2位流水号			
		*/
		var sql = "SELECT m_id FROM t_measure_set 
					WHERE 
						measure = :measure 
					ORDER BY m_id DESC ";
		
		var queryObj = new Query( datasource=application.dnsMaster, maxRows=1 );
		
		queryObj.addParam( name="measure", value=getMeasure(), cfsqltype="cf_sql_char" );

		var rs_check = queryObj.execute( sql=sql ).getResult();
		
		if ( rs_check.recordCount ) {
			/* 创建一个追加id */
			nextID = getMeasure() & numberFormat( ( right( rs_check.m_id, 2 ) + 1 ), "0_" );
		}

		return nextID;
	}
	
}

</cfscript>